home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (c) 1991, 1992 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that the name of Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE
- * POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
- /*
- * Copyright (C) 1990,91,92 Silicon Graphics, Inc.
- *
- *
- _______________________________________________________________________
- ______________ S I L I C O N G R A P H I C S I N C . ____________
- |
- | $Revision: 1.1000 $
- |
- | Classes: SvManipList
- |
- | Author(s): David Mott
- |
- ______________ S I L I C O N G R A P H I C S I N C . ____________
- _______________________________________________________________________
- */
-
- #include <Inventor/SbPList.h>
- #include <Inventor/SoPath.h>
- #include <Inventor/manips/SoManipulator.h>
- #include "SvManipList.h"
-
-
- // a path/manip pair
- typedef struct SvPathManipPair {
- SoPath *path;
- SoManipulator *manip;
- } SvPathManipPair;
-
- ////////////////////////////////////////////////////////////////////////
- //
- // Constructor
- //
- // Use: public
- SvManipList::SvManipList()
- //
- ////////////////////////////////////////////////////////////////////////
- {
- list = new SbPList;
- }
-
- ////////////////////////////////////////////////////////////////////////
- //
- // Destructor
- //
- // Use: public
- SvManipList::~SvManipList()
- //
- ////////////////////////////////////////////////////////////////////////
- {
- delete list;
- }
-
- ////////////////////////////////////////////////////////////////////////
- //
- // Append adds the path/manip pair to the list.
- // This ref()'s both the path and the manip.
- //
- // Use: public
- int
- SvManipList::getLength() const
- //
- ////////////////////////////////////////////////////////////////////////
- {
- return list->length();
- }
-
- ////////////////////////////////////////////////////////////////////////
- //
- // Append adds the path/manip pair to the list.
- // This ref()'s both the path and the manip.
- //
- // Use: public
- void
- SvManipList::append(SoPath *p, SoManipulator *m)
- //
- ////////////////////////////////////////////////////////////////////////
- {
- SvPathManipPair *pair = new SvPathManipPair;
-
- pair->path = p;
- pair->manip = m;
- p->ref();
- m->ref();
-
- list->append(pair);
- }
-
- ////////////////////////////////////////////////////////////////////////
- //
- // Find locates the first path/manip pair whose path is p,
- // and returns the index in the list of that pair.
- //
- // Use: public
- int
- SvManipList::find(SoPath *p) const
- //
- ////////////////////////////////////////////////////////////////////////
- {
- int which = -1;
-
- for (int i = 0; (i < list->length()) && (which == -1); i++) {
- SvPathManipPair *pair = (SvPathManipPair *) (*list)[i];
- if (*pair->path == *p)
- which = i;
- }
-
- return which;
- }
-
- ////////////////////////////////////////////////////////////////////////
- //
- // Find locates the first path/manip pair whose manip is m,
- // and returns the index in the list of that pair.
- //
- // Use: public
- int
- SvManipList::find(SoManipulator *m) const
- //
- ////////////////////////////////////////////////////////////////////////
- {
- int which = -1;
-
- for (int i = 0; (i < list->length()) && (which == -1); i++) {
- SvPathManipPair *pair = (SvPathManipPair *) (*list)[i];
- if (pair->manip == m)
- which = i;
- }
-
- return which;
- }
-
- ////////////////////////////////////////////////////////////////////////
- //
- // Remove removes the path/manip pair specified by which index from
- // the list. This unref()'s both the path and the manip.
- //
- // Use: public
- void
- SvManipList::remove(int which)
- //
- ////////////////////////////////////////////////////////////////////////
- {
- SvPathManipPair *pair = (SvPathManipPair *) (*list)[which];
-
- pair->path->unref();
- pair->manip->unref();
-
- list->remove(which);
- }
-
- ////////////////////////////////////////////////////////////////////////
- //
- // This returns the path in the path/manip pair specified by which index.
- //
- // Use: public
- SoPath *
- SvManipList::getPath(int which) const
- //
- ////////////////////////////////////////////////////////////////////////
- {
- SvPathManipPair *pair = (SvPathManipPair *) (*list)[which];
- return (pair->path);
- }
-
- ////////////////////////////////////////////////////////////////////////
- //
- // This returns the manip in the path/manip pair specified by which index.
- //
- // Use: public
- SoManipulator *
- SvManipList::getManip(int which) const
- //
- ////////////////////////////////////////////////////////////////////////
- {
- SvPathManipPair *pair = (SvPathManipPair *) (*list)[which];
- return (pair->manip);
- }
-
-